#include <iostream>
#include <atomic>
#include <thread>
#include <vector>
#include <mutex>

int a = 0;
int b = 0;
std::mutex mtx;

int ValueSet()
{
    int t = 1;
    {
        //std::lock_guard<std::mutex> lock(mtx);
        a = t;
        b = a;
    }
    return 0;
}

int Oberserver()
{
    int _a, _b;
    {
        //std::lock_guard<std::mutex> lock(mtx);
        _a = a;
        _b = b;
    }

    if (_a == 1 &&  _b== 0)
    {
        std::cout << "a:" << _a << "; b:" << _b << std::endl;
        return -1;
    }
    return 0;
}

int main()
{
    while (1)
    {
        a = 0;
        b = 0;
        std::thread t1(ValueSet);
        std::thread t2(Oberserver);
        t1.join();
        t2.join();
    }

    // std::cout << "a:" << a << "; b:" << b << std::endl;
    return 0;
}
